<script>
function syllabify(s) {
    var syls = [];
    
    s.replace(/[aeiou]/g, "V").replace(/[^V]/g, "C")
        .split("").reverse().join("").replace(/C?VC?/g, function (m, i) {
        syls.unshift(s.substr(s.length - i - m.length, m.length));
    });
    
    return syls;
}

function test(s, e) {
    document.write(s + ": ");
    document.write(syllabify(s) == e.toString() ? "PASS" : "FAIL");
    document.write("<br/>");
}

test("o", "o");
test("iz", "iz");
test("iki", "i,ki");
test("ikiz", "i,kiz");
test("ilk", "ilk");
test("ulke", "ul,ke");
test("asker", "as,ker");
test("su", "su");
test("sut", "sut");
test("sutu", "su,tu");
test("tuten", "tu,ten");
test("tren", "tren");
test("treni", "tre,ni");
test("trenim", "tre,nim");
test("trenci", "tren,ci");
test("klise", "kli,se");
</script>
